package com.jilefojing.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jilefojing.beans.vo.Pagination;
import com.jilefojing.beans.vo.Source;
import com.jilefojing.dao.ISourceDao;
import com.jilefojing.dao.mapper.ISourceMapper;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年07月22日 01时02分09秒
 */
@Repository
public class SourceDao implements ISourceDao {
	@Autowired
	private ISourceMapper sourceMapper;

	@Override
	public Pagination<Source> getPaginationByTitleLike(String titleLike,
			Pagination<Source> pagination) {
		if (pagination.isCounted()) {
			int count = sourceMapper.countByTitleLike(titleLike);
			pagination.setCount(count);
			if (count < 1) {
				return pagination;
			}
		}
		List<Source> sources = sourceMapper.getListByTitleLike(titleLike,
				pagination);
		pagination.setItems(sources);
		return pagination;
	}
}
